package com.cskaoyan.weixin.service;

import com.cskaoyan.bean.Feedback;
import com.cskaoyan.bean.User1;
import com.cskaoyan.mapper.FeedbackMapper;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.subject.Subject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;

@Service
public class WxFeedBackServiceImpl implements WxFeedBackService {

    @Autowired
    FeedbackMapper feedbackMapper;

    @Override
    public void submit(Feedback feedback) {
        feedback.setAddTime(new Date());
        feedback.setUpdateTime(new Date());
        Subject subject = SecurityUtils.getSubject();
        User1 user1 = (User1) subject.getPrincipal();
        String username = user1.getUsername();
        Integer id = user1.getId();
        feedback.setUsername(username);
        feedback.setUserId(id);
        feedbackMapper.insertSelective(feedback);
    }
}
